/**
 * Created by Administrator on 2017/11/14.
 */

function check_409() {

    var lastarr = new Array();
    var nowarr = new Array();
    $("input[name='last[]']").each(function () {
        lastarr[$(this).attr('id')] = $(this).val();
    })
    $("input[name='now[]']").each(function () {
        nowarr[$(this).attr('id')] = $(this).val();
    })
    if(isnumber(lastarr['last_b2']) == 2 || isnumber(lastarr['last_b3']) == 2 || isnumber(lastarr['last_b5']) == 2){
        return '请输入数字';
    }
    if(isnumber(nowarr['now_b2']) == 2 || isnumber(nowarr['now_b3']) == 2 || isnumber(nowarr['now_b5']) == 2){
        return '请输入数字';
    }
    if (parseInt(lastarr['last_b3'])>parseInt(lastarr['last_b2'])){
        return '上年主营业务收入不大于营业收入';
    }
    if (parseInt(nowarr['now_b3'])>parseInt(nowarr['now_b2'])){
        return '本年主营业务收入不大于营业收入';
    }

    if (parseInt(lastarr['last_b5'])>=parseInt(lastarr['last_b2'])){
        return '上年主营业务利润应小于营业收入';
    }
    if (parseInt(nowarr['now_b5'])>=parseInt(nowarr['now_b2'])){
        return '本年主营业务利润应小于营业收入';
    }

    if(isnumber(lastarr['last_b6']) == 2 || isnumber(lastarr['last_b7']) == 2 || isnumber(lastarr['last_b8']) == 2 || isnumber(lastarr['last_b9']) == 2 || isnumber(lastarr['last_b10']) == 2){
        return '请输入数字';
    }
    if(isnumber(nowarr['now_b6']) == 2 || isnumber(nowarr['now_b7']) == 2 || isnumber(nowarr['now_b8']) == 2 || isnumber(nowarr['now_b9']) == 2 || isnumber(nowarr['now_b10']) == 2){
        return '请输入数字';
    }

    if (lastarr['last_b7']!='' && lastarr['last_b8']!='' && lastarr['last_b9']!='' && lastarr['last_b10']!=''){
        var arr = new Array();
        arr[0] = lastarr['last_b7'];
        arr[1] = lastarr['last_b8'];
        arr[2] = lastarr['last_b9'];
        arr[3] = lastarr['last_b10'];
        var sum =  sumarray(arr);
        if (sum > parseInt(lastarr['last_b6'])){
            return '上年货运总量不小于子级分类之和';
        }
    }

    if (nowarr['now_b7']!='' && nowarr['now_b8']!='' && nowarr['now_b9']!='' && nowarr['now_b10']!=''){
        var arr = new Array();
        arr[0] = nowarr['now_b7'];
        arr[1] = nowarr['now_b8'];
        arr[2] = nowarr['now_b9'];
        arr[3] = nowarr['now_b10'];
        var sum =  sumarray(arr);
        if (sum > parseInt(nowarr['now_b6'])){
            return '本年货运总量不小于子级分类之和';
        }
    }

    if(isnumber(lastarr['last_b11']) == 2 || isnumber(lastarr['last_b12']) == 2 || isnumber(lastarr['last_b13']) == 2 || isnumber(lastarr['last_b14']) == 2 || isnumber(lastarr['last_b15']) == 2){
        return '请输入数字';
    }
    if(isnumber(nowarr['now_b11']) == 2 || isnumber(nowarr['now_b12']) == 2 || isnumber(nowarr['now_b13']) == 2 || isnumber(nowarr['now_b14']) == 2 || isnumber(nowarr['now_b15']) == 2){
        return '请输入数字';
    }

    if (lastarr['last_b12']!='' && lastarr['last_b13']!='' && lastarr['last_b14']!='' && lastarr['last_b15']!=''){
        var arr = new Array();
        arr[0] = lastarr['last_b12'];
        arr[1] = lastarr['last_b13'];
        arr[2] = lastarr['last_b14'];
        arr[3] = lastarr['last_b15'];
        var sum =  sumarray(arr);
        if (sum > parseInt(lastarr['last_b11'])){
            return '上年货运周转量不小于子级分类之和';
        }
    }

    if (nowarr['now_b12']!='' && nowarr['now_b13']!='' && nowarr['now_b14']!='' && nowarr['now_b15']!=''){
        var arr = new Array();
        arr[0] = nowarr['now_b12'];
        arr[1] = nowarr['now_b13'];
        arr[2] = nowarr['now_b14'];
        arr[3] = nowarr['now_b15'];
        var sum =  sumarray(arr);
        if (sum > parseInt(nowarr['now_b11'])){
            return '本年货运周转量不小于子级分类之和';
        }
    }

    if(isnumber(lastarr['last_b16']) == 2 || isnumber(lastarr['last_b17']) == 2 || isnumber(lastarr['last_b18']) == 2 || isnumber(lastarr['last_b19']) == 2 || isnumber(lastarr['last_b20']) == 2){
        return '请输入数字';
    }
    if(isnumber(nowarr['now_b16']) == 2 || isnumber(nowarr['now_b17']) == 2 || isnumber(nowarr['now_b18']) == 2 || isnumber(nowarr['now_b19']) == 2 || isnumber(nowarr['now_b20']) == 2){
        return '请输入数字';
    }

    if (lastarr['last_b17']!='' && lastarr['last_b18']!='' && lastarr['last_b19']!='' && lastarr['last_b20']!=''){
        var arr = new Array();
        arr[0] = lastarr['last_b17'];
        arr[1] = lastarr['last_b18'];
        arr[2] = lastarr['last_b19'];
        arr[3] = lastarr['last_b20'];
        var sum =  sumarray(arr);
        if (sum > parseInt(lastarr['last_b16'])){
            return '上年集装箱吞吐量不小于子级分类之和';
        }
    }

    if (nowarr['now_b17']!='' && nowarr['now_b18']!='' && nowarr['now_b19']!='' && nowarr['now_b20']!=''){
        var arr = new Array();
        arr[0] = nowarr['now_b17'];
        arr[1] = nowarr['now_b18'];
        arr[2] = nowarr['now_b19'];
        arr[3] = nowarr['now_b20'];
        var sum =  sumarray(arr);
        if (sum > parseInt(nowarr['now_b16'])){
            return '本年集装箱吞吐量不小于子级分类之和';
        }
    }

    if(isnumber(lastarr['last_b21']) == 2 || isnumber(lastarr['last_b22']) == 2 || isnumber(lastarr['last_b23']) == 2 || isnumber(lastarr['last_b24']) == 2 || isnumber(lastarr['last_b25']) == 2 || isnumber(lastarr['last_b43']) == 2){
        return '请输入数字';
    }
    if(isnumber(nowarr['now_b21']) == 2 || isnumber(nowarr['now_b22']) == 2 || isnumber(nowarr['now_b23']) == 2 || isnumber(nowarr['now_b24']) == 2 || isnumber(nowarr['now_b25']) == 2 || isnumber(nowarr['now_b43']) == 2){
        return '请输入数字';
    }

    if (lastarr['last_b22']!='' && lastarr['last_b25']!='' && lastarr['last_b43']!=''){
        var arr = new Array();
        arr[0] = lastarr['last_b22'];
        arr[1] = lastarr['last_b25'];
        arr[2] = lastarr['last_b43'];
        var sum =  sumarray(arr);
        if (sum != parseInt(lastarr['last_b21'])){
            return '上年21应等于22,25,43和';
        }
    }

    if (nowarr['now_b22']!='' && nowarr['now_b25']!='' && nowarr['now_b43']!=''){
        var arr = new Array();
        arr[0] = nowarr['now_b22'];
        arr[1] = nowarr['now_b25'];
        arr[2] = nowarr['now_b43'];
        var sum =  sumarray(arr);
        if (sum != parseInt(nowarr['now_b21'])){
            return '本年21应等于22,25,43和';
        }
    }

    if (lastarr['last_b23']!='' && lastarr['last_b24']!=''){
        var arr = new Array();
        arr[0] = lastarr['last_b23'];
        arr[1] = lastarr['last_b24'];
        var sum =  sumarray(arr);
        if (sum != parseInt(lastarr['last_b22'])){
            return '上年22应等于23,24和';
        }
    }

    if (nowarr['now_b23']!='' && nowarr['now_b24']!=''){
        var arr = new Array();
        arr[0] = nowarr['now_b23'];
        arr[1] = nowarr['now_b24'];
        var sum =  sumarray(arr);
        if (sum != parseInt(nowarr['now_b22'])){
            return '本年22应等于23,24和';
        }
    }

    if(isnumber(lastarr['last_b36']) == 2 || isnumber(lastarr['last_b37']) == 2 || isnumber(lastarr['last_b38']) == 2 || isnumber(lastarr['last_b40']) == 2){
        return '请输入数字';
    }
    if(isnumber(nowarr['now_b36']) == 2 || isnumber(nowarr['now_b37']) == 2 || isnumber(nowarr['now_b38']) == 2 || isnumber(nowarr['now_b40']) == 2){
        return '请输入数字';
    }

    if (lastarr['last_b37']!='' && lastarr['last_b38']!=''){
        var arr = new Array();
        arr[0] = lastarr['last_b37'];
        arr[1] = lastarr['last_b38'];
        var sum =  sumarray(arr);
        if (sum != parseInt(lastarr['last_b36'])){
            return '上年36应等于37,38的和！';
        }
    }

    if (nowarr['now_b37']!='' && nowarr['now_b38']!=''){
        var arr = new Array();
        arr[0] = nowarr['now_b37'];
        arr[1] = nowarr['now_b38'];
        var sum =  sumarray(arr);
        if (sum != parseInt(nowarr['now_b36'])){
            return '本年36应等于37,38的和！';
        }
    }

    if (lastarr['last_b40']!=''){
        if (parseInt(lastarr['last_b40'])>parseInt(lastarr['last_b36'])){
            return '上年40应不大于36人数！';
        }
    }
    if (nowarr['now_b40']!=''){
        if (parseInt(nowarr['now_b40'])>parseInt(nowarr['now_b36'])){
            return '本年40应不大于36人数！';
        }
    }

    return '';
}

function isnumber(str) {
    if (isNaN(str) && str !=''){
        return '2';
    }
}

function sumarray(arr) {
    var a = 0;
    for (var i=0;i<arr.length;i++){
        a += parseInt(arr[i]);
    }
    return a;
}